package utils

//
//import (
//	"reward-server/forms"
//	"reward-server/global"
//	"encoding/base64"
//	"github.com/aliyun/aliyun-oss-go-sdk/oss"
//	"strings"
//	"time"
//)
//func NewBucketPlain( ) (*oss.Bucket, error) {
//	// 创建OSSClient实例。
//	client, err := oss.New(global.ServerConfig.OssInfo.Endpoint, global.ServerConfig.OssInfo.ApiKey, global.ServerConfig.OssInfo.ApiSecrect)
//	if err != nil {
//		return nil, err
//	}
//
//	// 获取存储空间。
//	bucket, err := client.Bucket(global.ServerConfig.OssInfo.BucketName)
//	if err != nil {
//		return nil, err
//	}
//
//	return bucket, nil
//}
//
///*
//   @name 上传文件-字符串
//*/
//func UploadByStringPlain( params forms.UploadForm) (string, string, error) {
//
//	bucket, err := NewBucketPlain()
//	if err != nil {
//		return "", "", err
//	}
//	if params.FileName == ""{
//		//获取上传文件类型
//		fileTypePosition := strings.Index(params.Images,"/")
//		fileType := params.Images[fileTypePosition+1:fileTypePosition+5]
//		params.FileName = RandStringBytes(8) + "." + fileType   //代码生成图片名称
//	}
//
//	uploadPath := global.ServerConfig.OssInfo.UploadDir + "uploads" + "/" + time.Now().Format("2006-01-02") + "/" + params.FileName
//	//获取图片内容并base64解密
//	fileContentPosition := strings.Index(params.Images, ",")
//	uploadBaseString := params.Images[fileContentPosition+1:]
//	uploadString, _ := base64.StdEncoding.DecodeString(uploadBaseString)
//
//	err = bucket.PutObject(uploadPath, strings.NewReader(string(uploadString)))
//
//	if err != nil {
//		return uploadPath, uploadPath, err
//	}
//
//	return global.ServerConfig.OssInfo.Host + "/" + uploadPath, uploadPath, nil
//}
//
